﻿@model IEnumerable<WebApplication1.Models.ExamResult>

@{
    ViewBag.Title = "我的成绩";
}

<h2>我的成绩</h2>

<table class="table table-striped table-bordered">
    <thead>
        <tr>
            <th>考试名称</th>
            <th>得分</th>
            <th>总分</th>
            <th>百分比</th>
            <th>考试时间</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>@(item.Exam?.Name ?? "默认考试")</td>
                <td>@Html.DisplayFor(modelItem => item.Score)</td>
                <td>@Html.DisplayFor(modelItem => item.TotalScore)</td>
                <td>
                    @{
                        var percentage = item.TotalScore > 0 ? (int)Math.Round((double)item.Score / item.TotalScore * 100) : 0;
                        <span class="@(percentage >= 60 ? "text-success" : "text-danger")">@percentage%</span>
                    }
                </td>
                <td>@Html.DisplayFor(modelItem => item.ExamDate)</td>
            </tr>
        }
    </tbody>
</table>